<?php
use yii\helpers\Url;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
$data = \app\models\School::find()->where(['yey_xz'=>0])->all();

/* @var $this yii\web\View */
/* @var $model app\models\School */
/* @var $form yii\widgets\ActiveForm */
$this->registerJsFile('@web/js/jquery.cityselect.js',['depends'=>[\yii\web\JqueryAsset::className()]]);
$home = Url::base();
$prov = $model->yey_sheng;
$city = $model->yey_shi;
$js = <<<JS
$("#area").citySelect({
    
        url:"$home/js/city.min.js",   
        prov:"$prov", //省份  
        city:"$city", //城市  
    }
);

JS;
$this->registerJs($js);

?>


<div class="school-form">

    <?php

    if ($model->hasErrors()) {
        \yii\bootstrap\Alert::begin(
            [
                'options' => [
                    'class' => 'alert-warning',
                ]
            ]
        );
        echo Html::errorSummary($model);
        \yii\bootstrap\Alert::end();
    }
    ?>

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'yey_mingcheng')->textInput(['maxlength' => true]) ?>
    <?= $form->field($model, 'yey_type')->radioList([0=>'试用',1=>'正式'])?>
    <?= $form->field($model, 'yey_www')->textInput(['maxlength' => true]) ?>
    <?= $form->field($model, 'stu_num')->textInput(['maxlength' => true]) ?>



    <?= $form->field($model, 'yey_xz')->radioList([0=>'集团',1=>'幼儿园'])?>
    <?=  $form->field($model, 'yey_jg')->dropDownList(ArrayHelper::map($data,'yey_id', 'yey_mingcheng'),['prompt'=>'请选择所属机构']); ?>

    <?= $form->field($model, 'yz_name')->textInput(['maxlength' => true]) ?>
    <?= $form->field($model, 'yz_phone')->textInput(['maxlength' => true]) ?>
    <?= $form->field($model, 'gl_name')->textInput(['maxlength' => true]) ?>
    <?= $form->field($model, 'gl_phone')->textInput(['maxlength' => true]) ?>
    <div id="area" class="form-group required">
        <label class="control-label" for="school-yey_mingcheng">省市</label>
        <div class="form-inline">
            <select class="prov" id = "school-yey_sheng" name="School[yey_sheng]"></select>
            <select class="city" disabled="disabled" id="school-yey_shi" name="School[yey_shi]"></select>
        </div>
    </div>

    <?= $form->field($model, 'yey_jianjie')->textarea(['rows' => true]) ?>


    <?php if (!Yii::$app->request->isAjax){ ?>
	  	<div class="form-group">
	        <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
	    </div>
	<?php } ?>

    <?php ActiveForm::end(); ?>
    
</div>
